package core;

import java.text.DecimalFormat;

public class Edge
{
    char start;
    char end;

    boolean walk;
    boolean drive;
    boolean bus;

    boolean byBus;

    double dist;
    double walkTime;
    double busTime;

    private static final double INFINITY =Double.MAX_VALUE;
    private static final double SPEED=0.07;

    public Edge(char start,char end)
    {
        this.start=start;
        this.end=end;

        initial();
    }
    public void initial()
    {
        walk=true;
        drive=true;
        bus=false;
        busTime=INFINITY;
        walkTime=INFINITY;
    }

    public boolean getDrive()
    {
        return drive;
    }
    public boolean getBus()
    {
        return bus;
    }
    public boolean getWalk()
    {
        return walk;
    }
    public double getBusTime()
    {
        return busTime;
    }
    public double getTime()
    {
        if (busTime<=walkTime)
        {
            byBus=true;
            return busTime;
        }
        else
        {
            byBus=false;
            return walkTime;
        }
    }
    public double getWeight(int mode)
    {
        double weight;
        switch (mode)
        {
            case 1:weight=getTime();break;
            default:weight=dist;break;
        }

        return weight;
    }
    public boolean getByBus()
    {
        return byBus;
    }

    public void setDist(double dist)
    {
        int tmp=(int)((dist+0.005)*100);
        this.dist=tmp/100.00;
    }
    public void setBusTime(double busTime)
    {
        int tmp=(int)((busTime+0.005)*100);
        this.busTime=tmp/100.00;
    }
    public void setWalkTime()
    {
        if (dist>0)
        {
            walkTime=dist/SPEED;
            int tmp=(int)((walkTime+0.005)*100);
            walkTime=tmp/100.00;
        }

    }
    public void setMode(boolean walk,boolean drive,boolean bus)
    {
        this.walk=walk;
        this.drive=drive;
        this.bus=bus;
    }
    public void setWalk(boolean walk)
    {
        this.walk=walk;
    }
    public void setBus(boolean bus)
    {
        this.bus=bus;
    }
    public void setDrive(boolean drive)
    {
        this.drive=drive;
    }
}
